package com.example.springboot.service.Impl;

import com.example.springboot.entity.UserSearchRemember;
import com.example.springboot.entity.vo.UserSearchRememberVo;
import com.example.springboot.mapper.UserSearchRememberMapper;
import com.example.springboot.service.UserSearchRememberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserSearchRememberServiceImpl implements UserSearchRememberService {

    @Autowired
    private UserSearchRememberMapper userSearchRememberMapper;

    @Override
    public int addUserSearchRemember(UserSearchRemember userSearchRemember) {
        userSearchRemember.setCreatedAt(new java.sql.Timestamp(System.currentTimeMillis()));
        userSearchRemember.setUpdatedAt(new java.sql.Timestamp(System.currentTimeMillis()));
        return userSearchRememberMapper.insert(userSearchRemember);
    }

    @Override
    public int deleteUserSearchRemember(int id) {
        return userSearchRememberMapper.deleteById(id);
    }

    @Override
    public int updateUserSearchRemember(UserSearchRemember userSearchRemember) {
        return userSearchRememberMapper.update(userSearchRemember);
    }

    @Override
    public UserSearchRemember getUserSearchRememberById(int id) {
        return userSearchRememberMapper.findById(id);
    }

    @Override
    public List<UserSearchRemember> getUserSearchRememberByUserId(int userId) {
        return userSearchRememberMapper.findByUserId(userId);
    }

    @Override
    public List<UserSearchRememberVo> findHotSearch() {
        return userSearchRememberMapper.findHotSearch();
    }
}